#ifndef EJSQLMANAGER_H
#define EJSQLMANAGER_H
#include <QMap>
#include <QSqlDatabase>
#include <QSqlTableModel>

class EJSqlManager
{
public:
    ~EJSqlManager();

    bool open(const QString &path, const QString &passwd);

    bool query(const QString &sql, const QString &path = "");

    bool existTable(const QString &table = "", const QString &path = "");

    bool createTable(const QStringList &column, const QString &table = "", const QString &path = "");

    void setDefaultDB(const QString &path){m_defaultDB = path;}
    void setDefaultTB(const QString &table){m_defaultTB = table;}

    QSqlTableModel *getTableModel(const QString &table = "", const QString &path = "");

    static EJSqlManager* getInstance(){return m_instance;}

private:
    EJSqlManager(){}
private:
    QMap<QString, QSqlDatabase> m_dbconn;

    QString              m_defaultDB;
    QString              m_defaultTB;
    static EJSqlManager *m_instance;
};

#endif // EJSQLMANAGER_H
